std.digest.*: clean imports

This commit is contained in:
Ilya Yaroshenko 2014-11-10 15:00:44 +03:00
parent 05663e88fe
commit cd76ad7ac3
5 changed files with 16 additions and 11 deletions

View file

@ -63,7 +63,6 @@ public import std.digest.digest;
version(unittest)
import std.exception;
import std.bitmanip;
///
unittest
@ -219,6 +218,7 @@ struct CRC32
*/
ubyte[4] peek() const @safe pure nothrow @nogc
{
import std.bitmanip : nativeToLittleEndian;
//Complement, LSB first / Little Endian, see http://rosettacode.org/wiki/CRC-32
return nativeToLittleEndian(~_state);
}

View file

@ -64,10 +64,11 @@ $(TR $(TDNW Implementation helpers) $(TD $(MYREF digestLength) $(MYREF WrapperDi
*/
module std.digest.digest;
import std.range, std.traits;
import std.traits;
import std.typetuple : allSatisfy;
public import std.ascii : LetterCase;
///
unittest
{
@ -280,6 +281,7 @@ unittest
*/
template isDigest(T)
{
import std.range : isOutputRange;
enum bool isDigest = isOutputRange!(T, const(ubyte)[]) && isOutputRange!(T, ubyte) &&
is(T == struct) &&
is(typeof(
@ -387,6 +389,7 @@ unittest
private template isDigestibleRange(Range)
{
import std.digest.md;
import std.range : isInputRange, ElementType;
enum bool isDigestibleRange = isInputRange!Range && is(typeof(
{
MD5 ha; //Could use any conformant hash
@ -416,6 +419,7 @@ DigestType!Hash digest(Hash, Range)(auto ref Range range) if(!isArray!Range
unittest
{
import std.digest.md;
import std.range : repeat;
auto testRange = repeat!ubyte(cast(ubyte)'a', 100);
auto md5 = digest!MD5(testRange);
}
@ -472,6 +476,7 @@ char[digestLength!(Hash)*2] hexDigest(Hash, Order order = Order.increasing, Rang
unittest
{
import std.digest.md;
import std.range : repeat;
auto testRange = repeat!ubyte(cast(ubyte)'a', 100);
assert(hexDigest!MD5(testRange) == "36A92CC94A9E0FA21F625F8BFB007ADF");
}
@ -627,6 +632,7 @@ unittest
unittest
{
import std.range : isOutputRange;
assert(!isDigest!(Digest));
assert(isOutputRange!(Digest, ubyte));
}
@ -736,6 +742,7 @@ string toHexString(Order order = Order.increasing, LetterCase letterCase = Lette
}
else
{
import std.range : retro;
foreach(u; retro(digest))
{
result[i++] = hexDigits[u >> 4];

View file

@ -46,8 +46,6 @@ $(TR $(TDNW Helpers) $(TD $(MYREF md5Of))
*/
module std.digest.md;
import std.bitmanip, std.exception, std.string;
public import std.digest.digest;
///
@ -362,6 +360,8 @@ struct MD5
*/
ubyte[16] finish() @trusted pure nothrow @nogc
{
import std.bitmanip : nativeToLittleEndian;
ubyte[16] data = void;
ubyte[8] bits = void;
uint index, padLen;

View file

@ -47,8 +47,6 @@ $(TR $(TDNW Helpers) $(TD $(MYREF ripemd160Of))
module std.digest.ripemd;
import std.bitmanip, std.exception, std.string;
public import std.digest.digest;
///
@ -528,6 +526,8 @@ struct RIPEMD160
*/
ubyte[20] finish() @trusted pure nothrow @nogc
{
import std.bitmanip : nativeToLittleEndian;
ubyte[20] data = void;
ubyte[8] bits = void;
uint index, padLen;

View file

@ -119,9 +119,7 @@ else version(D_InlineAsm_X86_64)
private version = USE_SSSE3;
}
import std.ascii : hexDigits;
import std.exception : assumeUnique;
import core.bitop : bswap;
version(LittleEndian) import core.bitop : bswap;
version(USE_SSSE3) import core.cpuid : hasSSSE3Support = ssse3;
version(USE_SSSE3) import std.internal.digest.sha_SSSE3 : transformSSSE3;
@ -160,8 +158,8 @@ private ulong bigEndianToNative(ubyte[8] val) @trusted pure nothrow @nogc
{
version(LittleEndian)
{
static import std.bitmanip;
return std.bitmanip.bigEndianToNative!ulong(val);
import std.bitmanip : bigEndianToNative;
return bigEndianToNative!ulong(val);
}
else
return *cast(ulong*) &val;