public class Security extends Object
| Modifier and Type | Method and Description | 
|---|---|
static String | 
decrypt(String text)
Deprecated. 
 
As of version 2.4.0, this method is not referenced in openmrs-core or any other projects under the
 GitHub OpenMRS organisation. 
 | 
static String | 
decrypt(String text,
       byte[] initVector,
       byte[] secretKey)
decrypt text to a string with specific initVector and secretKey; rarely used except in
 testing and where specifically necessary 
 | 
static String | 
encodeString(String strToEncode)
/**
 This method will hash  
strToEncode using the preferred algorithm. | 
static String | 
encrypt(String text)
Deprecated. 
 
As of version 2.4.0, this method is not referenced in openmrs-core or any other projects under the
 GitHub OpenMRS organisation. 
 | 
static String | 
encrypt(String text,
       byte[] initVector,
       byte[] secretKey)
encrypt text to a string with specific initVector and secretKey; rarely used except in
 testing and where specifically necessary 
 | 
static byte[] | 
generateNewInitVector()
generate a new cipher initialization vector; should only be called once in order to not
 invalidate all encrypted data 
 | 
static byte[] | 
generateNewSecretKey()
generate a new secret key; should only be called once in order to not invalidate all
 encrypted data 
 | 
static String | 
getRandomToken()
This method will generate a random string 
 | 
static byte[] | 
getSavedInitVector()
retrieve the stored init vector from runtime properties 
 | 
static byte[] | 
getSavedSecretKey()
retrieve the secret key from runtime properties 
 | 
static boolean | 
hashMatches(String hashedPassword,
           String passwordToHash)
Compare the given hash and the given string-to-hash to see if they are equal. 
 | 
public static boolean hashMatches(String hashedPassword, String passwordToHash)
hashedPassword - a stored password that has been hashed previouslypasswordToHash - a string to encode/hash and compare to hashedPasswordpublic static String encodeString(String strToEncode) throws APIException
strToEncode using the preferred algorithm. Currently,
 OpenMRS's preferred algorithm is hard coded to be SHA-512.strToEncode - string to encodeAPIExceptionpublic static String getRandomToken() throws APIException
APIExceptionpublic static String encrypt(String text, byte[] initVector, byte[] secretKey)
text - string to be encryptedinitVector - custom init vector byte arraysecretKey - custom secret key byte arrayencrypt(String)@Deprecated public static String encrypt(String text)
text - the text to encryptpublic static String decrypt(String text, byte[] initVector, byte[] secretKey)
text - text to be decryptedinitVector - custom init vector byte arraysecretKey - custom secret key byte arraydecrypt(String)@Deprecated public static String decrypt(String text)
text - text to be decryptedpublic static byte[] getSavedInitVector()
public static byte[] generateNewInitVector()
public static byte[] getSavedSecretKey()
public static byte[] generateNewSecretKey()
Copyright © 2024 OpenMRS Inc.. All rights reserved.