diff --git a/source/app.d b/source/app.d index 78aef1b..5376a37 100644 --- a/source/app.d +++ b/source/app.d @@ -66,7 +66,8 @@ int main(string[] args) result.helpWanted = true; } - printHelp(result.options); + if(result.helpWanted) + printHelp(result.options); return 0; } diff --git a/source/bitmanip.d b/source/bitmanip.d index 1d4f5cb..bafb3cb 100644 --- a/source/bitmanip.d +++ b/source/bitmanip.d @@ -1,7 +1,6 @@ module bitmanip; private import std.traits : isUnsigned; -private import std.bitmanip : nativeToLittleEndian, littleEndianToNative; UIntType rotateLeft(UIntType)(in UIntType val, in size_t len) nothrow @nogc pure @safe if(isUnsigned!UIntType) @@ -36,26 +35,3 @@ unittest assert(test[2].rotateRight(1) == 64); assert(test[2].rotateRight(7) == 1); } - -alias littleEndianInv = nativeToLittleEndian; - -uint littleEndian(in ubyte[] input) @safe pure nothrow @nogc -in -{ - assert(input.length == uint.sizeof); -} -body -{ - ubyte[uint.sizeof] buf = input; - return littleEndianToNative!uint(buf); -} - -unittest -{ - ubyte[] test0 = [0, 0, 0, 0]; - ubyte[] test1 = [86, 75, 30, 9]; - ubyte[] test2 = [255, 255, 255, 250]; - assert(littleEndian(test0) == 0x00000000); - assert(littleEndian(test1) == 0x091e4b56); - assert(littleEndian(test2) == 0xfaffffff); -} diff --git a/source/chacha20.d b/source/chacha20.d index f738a9f..2ed0b9c 100644 --- a/source/chacha20.d +++ b/source/chacha20.d @@ -2,10 +2,10 @@ module chacha20; private import std.string : format; private import std.range : isInputRange, isForwardRange, ElementType; -private import std.bitmanip : nativeToLittleEndian, littleEndianToNative; private import std.array; private import bitmanip; +private import endian; public: diff --git a/source/endian.d b/source/endian.d new file mode 100644 index 0000000..322852c --- /dev/null +++ b/source/endian.d @@ -0,0 +1,24 @@ +private import std.bitmanip : nativeToLittleEndian, littleEndianToNative; + +alias littleEndianInv = nativeToLittleEndian; + +uint littleEndian(in ubyte[] input) @safe pure nothrow @nogc +in +{ + assert(input.length == uint.sizeof); +} +body +{ + ubyte[uint.sizeof] buf = input; + return littleEndianToNative!uint(buf); +} + +unittest +{ + ubyte[] test0 = [0, 0, 0, 0]; + ubyte[] test1 = [86, 75, 30, 9]; + ubyte[] test2 = [255, 255, 255, 250]; + assert(littleEndian(test0) == 0x00000000); + assert(littleEndian(test1) == 0x091e4b56); + assert(littleEndian(test2) == 0xfaffffff); +} diff --git a/source/salsa20.d b/source/salsa20.d index 58bcc04..a2cc631 100644 --- a/source/salsa20.d +++ b/source/salsa20.d @@ -1,11 +1,11 @@ module salsa20; -private import std.traits : isUnsigned; private import std.string : format; private import std.range : isInputRange, isForwardRange, ElementType; private import std.array; private import bitmanip; +private import endian; public: