Class WinCrypt


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

      Constructors 
      Constructor Description
      WinCrypt()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.sun.jna.platform.win32.WinDef.BOOL CryptAcquireContextW​(com.sun.jna.Pointer phProv, com.sun.jna.WString pszContainer, com.sun.jna.WString pszProvider, int dwProvType, int dwFlags)
      Acquires the crypt context.
      static com.sun.jna.platform.win32.WinDef.BOOL CryptGenRandom​(com.sun.jna.platform.win32.WinDef.ULONG hProv, int dwLen, com.sun.jna.Pointer pbBuffer)
      Generates random data.
      static com.sun.jna.platform.win32.WinDef.BOOL CryptReleaseContext​(com.sun.jna.platform.win32.WinDef.ULONG hProv, int dwFlags)
      Releases the crypt context.
      static byte[] getRandomFromWindows​(int numBytes)
      Gets random numbers from Windows API.
      • Methods inherited from class java.lang.Object

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

      • JNA_LIBRARY_NAME

        public static final java.lang.String JNA_LIBRARY_NAME
        See Also:
        Constant Field Values
      • JNA_NATIVE_LIB

        public static final com.sun.jna.NativeLibrary JNA_NATIVE_LIB
    • Constructor Detail

      • WinCrypt

        public WinCrypt()
    • Method Detail

      • CryptAcquireContextW

        public static com.sun.jna.platform.win32.WinDef.BOOL CryptAcquireContextW​(com.sun.jna.Pointer phProv,
                                                                                  com.sun.jna.WString pszContainer,
                                                                                  com.sun.jna.WString pszProvider,
                                                                                  int dwProvType,
                                                                                  int dwFlags)
        Acquires the crypt context.
      • CryptReleaseContext

        public static com.sun.jna.platform.win32.WinDef.BOOL CryptReleaseContext​(com.sun.jna.platform.win32.WinDef.ULONG hProv,
                                                                                 int dwFlags)
        Releases the crypt context.
      • CryptGenRandom

        public static com.sun.jna.platform.win32.WinDef.BOOL CryptGenRandom​(com.sun.jna.platform.win32.WinDef.ULONG hProv,
                                                                            int dwLen,
                                                                            com.sun.jna.Pointer pbBuffer)
        Generates random data.
      • getRandomFromWindows

        public static byte[] getRandomFromWindows​(int numBytes)
        Gets random numbers from Windows API.
        Parameters:
        numBytes - Number of bytes requested.
        Returns:
        Random data, null on failure.