Package net.snowflake.ingest.utils
Class Cryptor
- java.lang.Object
-
- net.snowflake.ingest.utils.Cryptor
-
public class Cryptor extends Object
-
-
Constructor Summary
Constructors Constructor Description Cryptor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decrypt(byte[] input, String encryptionKey, String diversifier, long iv)Decrypts input bytes using AES CTR mode with zero initialization vector,this is used in testing onlystatic byte[]encrypt(byte[] compressedChunkData, String encryptionKey, String diversifier, long iv)Encrypts input bytes using AES CTR mode with zero initialization vector.static byte[]sha256Hash(byte[] input)Hashes input bytes using SHA-256.static byte[]sha256Hash(byte[] input, int offset, int len)Hashes input bytes using SHA-256.static Stringsha256HashBase64(byte[] input)Hashes input bytes using SHA-256 and converts hash into a string using Base64 encoding.
-
-
-
Method Detail
-
sha256Hash
public static byte[] sha256Hash(byte[] input, int offset, int len)Hashes input bytes using SHA-256.- Parameters:
input- input bytesoffset- offset into the output buffer to begin storing the digestlen- number of bytes within buf allotted for the digest- Returns:
- SHA-256 hash
-
sha256Hash
public static byte[] sha256Hash(byte[] input)
Hashes input bytes using SHA-256.- Parameters:
input- input bytes- Returns:
- SHA-256 hash
-
sha256HashBase64
public static String sha256HashBase64(byte[] input)
Hashes input bytes using SHA-256 and converts hash into a string using Base64 encoding.- Parameters:
input- input bytes- Returns:
- Base64-encoded SHA-256 hash
-
encrypt
public static byte[] encrypt(byte[] compressedChunkData, String encryptionKey, String diversifier, long iv) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingExceptionEncrypts input bytes using AES CTR mode with zero initialization vector.- Parameters:
compressedChunkData- bytes to encryptencryptionKey- symmetric encryption keydiversifier- diversifier for the encryption keyiv- IV to use for encryption- Returns:
- encrypted bytes, padded, prefixed with initialization vector
- Throws:
NoSuchPaddingExceptionNoSuchAlgorithmExceptionInvalidAlgorithmParameterExceptionInvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingException
-
decrypt
public static byte[] decrypt(byte[] input, String encryptionKey, String diversifier, long iv) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingExceptionDecrypts input bytes using AES CTR mode with zero initialization vector,this is used in testing only- Parameters:
input- bytes to encryptencryptionKey- symmetric encryption keydiversifier- diversifier for the decryption keyiv- IV to use for decryption- Returns:
- decrypted ciphertext
- Throws:
NoSuchPaddingExceptionNoSuchAlgorithmExceptionInvalidAlgorithmParameterExceptionInvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingException
-
-