Package no.polaric.core.util
Class SecUtils
java.lang.Object
no.polaric.core.util.SecUtils
Some utilities related to security.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final byte[]
Compute a hash from the text.static final String
b2hex
(byte[] bytes) Hexadecimal representation of a byte array.static final byte[]
static final String
b64encode
(byte[] x) static final byte[]
Deprecated.MD5 is cryptographically broken and should not be used for security purposes.static final String
Deprecated.This method uses MD5 which is cryptographically broken.static final String
Deprecated.This method uses MD5 which is cryptographically broken.static String
static final byte[]
getRandom
(int size) Generate a random key.static final byte[]
static final String
static final String
static final byte[]
static final String
xDigestB64
(String txt, int n) static final String
xDigestHex
(String txt)
-
Constructor Details
-
SecUtils
public SecUtils()
-
-
Method Details
-
getRandom
public static final byte[] getRandom(int size) Generate a random key. -
_digest
Compute a hash from the text. Text can be given as an array of bytes, a string or both. A string will be converted to bytes using the UTF-8 encoding before computing the hash. -
digest
Deprecated.MD5 is cryptographically broken and should not be used for security purposes. Use xDigest() for SHA-256 instead. This method is retained only for compatibility with legacy systems that require MD5.Computes MD5 hash. -
xDigest
-
hmac
-
digestHex
Deprecated.This method uses MD5 which is cryptographically broken. Use xDigestHex() instead.Compute a hash from the text, represented as a hexadecimal string. -
xDigestHex
-
hmacHex
-
digestB64
Deprecated.This method uses MD5 which is cryptographically broken. Use xDigestB64() instead.Base 64 encoded digest. Returns n first characters of digest, encoded using the Base 64 method. -
xDigestB64
-
hmacB64
-
b64encode
-
b64decode
-
b2hex
Hexadecimal representation of a byte array. -
escape4regex
-