Class CryptoBridge

java.lang.Object
kz.greetgo.security.crypto.CryptoBridge
All Implemented Interfaces:
Crypto

public class CryptoBridge
extends java.lang.Object
implements Crypto
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static CryptoTrace trace  
  • Constructor Summary

    Constructors 
    Constructor Description
    CryptoBridge​(CryptoSource cryptoSource)  
  • Method Summary

    Modifier and Type Method Description
    byte[] decrypt​(byte[] encryptedBytes)
    Decrypt encrypted data using private key
    byte[] encrypt​(byte[] bytes)
    Encrypt data using public key
    byte[] makeHash​(byte[] sourceBytes)
    Generate hash
    java.security.SecureRandom rnd()
    Gives security random generator
    byte[] sign​(byte[] bytes)
    Sign data
    boolean verifySignature​(byte[] bytes, byte[] signature)
    Verifies signature

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • encrypt

      public byte[] encrypt​(byte[] bytes)
      Description copied from interface: Crypto
      Encrypt data using public key
      Specified by:
      encrypt in interface Crypto
      Parameters:
      bytes - data to encrypt
      Returns:
      encrypted data
    • decrypt

      public byte[] decrypt​(byte[] encryptedBytes)
      Description copied from interface: Crypto
      Decrypt encrypted data using private key
      Specified by:
      decrypt in interface Crypto
      Parameters:
      encryptedBytes - encrypted data
      Returns:
      decrypted (original) data
    • sign

      public byte[] sign​(byte[] bytes)
      Description copied from interface: Crypto
      Sign data
      Specified by:
      sign in interface Crypto
      Parameters:
      bytes - the data to sign
      Returns:
      signature
    • verifySignature

      public boolean verifySignature​(byte[] bytes, byte[] signature)
      Description copied from interface: Crypto
      Verifies signature
      Specified by:
      verifySignature in interface Crypto
      Parameters:
      bytes - checking data
      signature - verifying signature
      Returns:
      verification result: true - verification is OK, otherwise - verification wrong
    • makeHash

      public byte[] makeHash​(byte[] sourceBytes)
      Description copied from interface: Crypto
      Generate hash
      Specified by:
      makeHash in interface Crypto
      Parameters:
      sourceBytes - source data
      Returns:
      hash
    • rnd

      public java.security.SecureRandom rnd()
      Description copied from interface: Crypto
      Gives security random generator
      Specified by:
      rnd in interface Crypto
      Returns:
      security random generator