Class UtilsCrypto


  • public class UtilsCrypto
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      UtilsCrypto()  
    • Method Summary

      Modifier and Type Method Description
      static byte[] blake2AsU8a​(byte[] data)  
      static byte[] blake2AsU8a​(byte[] data, int bitLength)  
      static byte[] blake2AsU8a​(byte[] data, int bitLength, byte[] key)
      Creates a blake2b u8a from the input.
      static void main​(java.lang.String[] args)  
      static java.lang.String randomAsHex()  
      static java.lang.String randomAsHex​(int length)  
      static byte[] randomAsU8a()  
      static byte[] randomAsU8a​(int length)
      Creates a Uint8Array filled with random bytes.
      static java.math.BigInteger xxhash64AsBn​(byte[] data, long seed)
      Creates a xxhash BN from the input.
      static java.lang.String xxhash64AsRaw​(byte[] data, long seed)
      Creates a xxhash non-prefixed hex from the input.
      static long xxhash64AsValue​(byte[] data, long seed)
      Creates a hex number from the input.
      static byte[] xxhashAsU8a​(byte[] data)
      Creates a xxhash64 u8a from the input.
      static byte[] xxhashAsU8a​(byte[] data, int bitLength)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UtilsCrypto

        public UtilsCrypto()
    • Method Detail

      • blake2AsU8a

        public static byte[] blake2AsU8a​(byte[] data,
                                         int bitLength,
                                         byte[] key)
        Creates a blake2b u8a from the input. From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. **example**

        ```java blake2AsU8a("abc"); // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] ```

      • blake2AsU8a

        public static byte[] blake2AsU8a​(byte[] data)
      • blake2AsU8a

        public static byte[] blake2AsU8a​(byte[] data,
                                         int bitLength)
      • xxhashAsU8a

        public static byte[] xxhashAsU8a​(byte[] data)
        Creates a xxhash64 u8a from the input. From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. **example**

        ```java xxhashAsU8a("abc"); // => 0x44bc2cf5ad770999 ```

      • xxhashAsU8a

        public static byte[] xxhashAsU8a​(byte[] data,
                                         int bitLength)
      • xxhash64AsBn

        public static java.math.BigInteger xxhash64AsBn​(byte[] data,
                                                        long seed)
        Creates a xxhash BN from the input. From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. **example**

        ```java xxhash64AsBn("abcd", 0xabcd)); // => new BN(0xe29f70f8b8c96df7) ```

      • xxhash64AsRaw

        public static java.lang.String xxhash64AsRaw​(byte[] data,
                                                     long seed)
        Creates a xxhash non-prefixed hex from the input. From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. **example**

        ```java xxhash64AsRaw("abcd", 0xabcd)); // => e29f70f8b8c96df7 ```

      • xxhash64AsValue

        public static long xxhash64AsValue​(byte[] data,
                                           long seed)
        Creates a hex number from the input. From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex number **example**

        ```java xxhash64AsValue("abcd", 0xabcd)); // => e29f70f8b8c96df7 ```

      • randomAsU8a

        public static byte[] randomAsU8a​(int length)
        Creates a Uint8Array filled with random bytes. Returns a `Uint8Array` with the specified (optional) length filled with random bytes. **example**

        ```java randomAsU8a(); // => Uint8Array([...]) ```

      • randomAsU8a

        public static byte[] randomAsU8a()
      • randomAsHex

        public static java.lang.String randomAsHex​(int length)
      • randomAsHex

        public static java.lang.String randomAsHex()
      • main

        public static void main​(java.lang.String[] args)