当前位置: 首页>>代码示例>>Java>>正文


Java NativeLong.intValue方法代码示例

本文整理汇总了Java中com.sun.jna.NativeLong.intValue方法的典型用法代码示例。如果您正苦于以下问题:Java NativeLong.intValue方法的具体用法?Java NativeLong.intValue怎么用?Java NativeLong.intValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jna.NativeLong的用法示例。


在下文中一共展示了NativeLong.intValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cryptoPwhashScryptSalsa208Sha256

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
public static byte[] cryptoPwhashScryptSalsa208Sha256(byte[] passwd, byte[] salt,
        Long opsLimit,
        NativeLong memLimit) throws SodiumLibraryException
{
    NativeLong salt_length = sodium().crypto_pwhash_scryptsalsa208sha256_saltbytes();
    if (salt.length != salt_length.intValue())
    {
        throw new SodiumLibraryException("salt is " + salt.length + ", it must be" + salt_length + " bytes");
    }
    byte[] key = new byte[sodium().crypto_box_seedbytes().intValue()];
    int rc = sodium().crypto_pwhash_scryptsalsa208sha256(key, key.length, 
            passwd, passwd.length,
            salt,
            opsLimit, memLimit);
    
    logger.info("crypto_pwhash_scryptsalsa208sha256 returned: " + rc);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_pwhash_scryptsalsa208sha256() failed, returned " + rc + ", expected 0");
    }
    return key;

}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:24,代码来源:SodiumLibrary.java

示例2: cryptoBoxEasy

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
/**
* Encrypts a message with recipient's public key.
* 
* Usage: Alice encrypts a message with Bob's public key and creates authentication tag with her private key
* 
* @param message The message to encrypt
* @param nonce {@link SodiumLibrary#cryptoBoxNonceBytes()} bytes of nonce. It must be preserved  because it will be needed during decryption
* @param publicKey Recipient's public key for encrypting the message
* @param privateKey Sender's private key for creating authentication tag
* @throws SodiumLibraryException on error
* @return encrypted message as an array of bytes
*/    
public static byte[] cryptoBoxEasy(byte[] message, byte[] nonce,
        byte[] publicKey, byte[] privateKey) throws SodiumLibraryException
{
    NativeLong nonce_len = sodium().crypto_box_noncebytes();
    if (nonce.length != nonce_len.intValue())
    {
        throw new SodiumLibraryException("nonce is " + nonce.length + "bytes, it must be" + nonce_len + " bytes");
    }
    byte[] cipherText = new byte[(sodium().crypto_box_macbytes().intValue() + message.length)];
    int rc = sodium().crypto_box_easy(cipherText,
            message,message.length,
            nonce,
            publicKey, privateKey);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_box_easy() failed, returned " + rc + ", expected 0");
    }

    return cipherText;
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:33,代码来源:SodiumLibrary.java

示例3: cryptoBoxOpenEasy

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
/**
* Recipient decrypts a message with his private key.
* 
* Usage: Bob (recipient) verifies the message with Alice's (sender) public key and 
* decrypts the message with his private key.
*
* @param cipherText Message to decrypt
* @param nonce Nonce used during encryption 
* @param publicKey Sender's (Alice) public key for verifying the message
* @param privateKey Recipient's (Bob)  Private key to decrypt the message
* @throws SodiumLibraryException on error
* @return Decrypted message as an array of bytes.
*/
public static byte[] cryptoBoxOpenEasy(byte[] cipherText, byte[]nonce, 
        byte[] publicKey, byte[] privateKey) throws SodiumLibraryException
{
    NativeLong nonce_len = sodium().crypto_box_noncebytes();
    if (nonce.length != nonce_len.intValue())
    {
        throw new SodiumLibraryException("nonce is " + nonce.length + "bytes, it must be" + nonce_len + " bytes");
    }
    byte[] decrypted = new byte[(int) (cipherText.length - sodium().crypto_box_macbytes().intValue())];
    int rc = sodium().crypto_box_open_easy(decrypted, cipherText, 
            cipherText.length, nonce, 
            publicKey, privateKey);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_box_open_easy() failed, returned " + rc + ", expected 0");
    }
    
    return decrypted;
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:33,代码来源:SodiumLibrary.java

示例4: invoke

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
@Override
public void invoke(Pointer streamRef, Pointer clientCallBackInfo, NativeLong numEvents, Pointer eventPaths, Pointer eventFlags, Pointer eventIds) {
    final long st = System.currentTimeMillis();
    final int length = numEvents.intValue();
    final Pointer[] pointers = eventPaths.getPointerArray(0, length);
    int flags[];
    if (eventFlags == null) {
        flags = new int[length];
        LOG.log(DEBUG_LOG_LEVEL, "FSEventStreamCallback eventFlags == null, expected int[] of size {0}", length); //NOI18N
    } else {
        flags = eventFlags.getIntArray(0, length);
    }
    for (int i=0; i<length; i++) {
        final Pointer p = pointers[i];
        int flag = flags[i];
        final String path = p.getString(0);

        if ((flag & kFSEventStreamEventFlagMustScanSubDirs) ==  kFSEventStreamEventFlagMustScanSubDirs ||
            (flag & kFSEventStreamEventFlagMount) == kFSEventStreamEventFlagMount ||
            (flag & kFSEventStreamEventFlagUnmount) == kFSEventStreamEventFlagUnmount) {
            events.add(ALL_CHANGE);
        } else {
            events.add(path);
        }
        LOG.log(DEBUG_LOG_LEVEL, "Event on {0}", new Object[]{path});
    }
    LOG.log(PERF_LOG_LEVEL, "Callback time: {0}", (System.currentTimeMillis() - st));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:OSXNotifier.java

示例5: getBuffer

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
public ByteBuffer getBuffer() {
  NativeLong length = _getLength();
  if (length.intValue() <= 0)
    return ByteBuffer.allocate(0);
  CFRange.ByValue range = new CFRange.ByValue();
  range.length = length;
  range.location = ZERO;
  ByteBuffer buffer = ByteBuffer.allocate(length.intValue());
  CFLibrary.INSTANCE.CFDataGetBytes(this, range, buffer);
  return buffer;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:12,代码来源:CFData.java

示例6: cryptoPwhashScrypt

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
/**
 * Derive key from a password using scrypt.
 * <p>
 * Excerpt from libsodium documentation:
 * <blockquote>
 * Scrypt was also designed to make it costly to perform large-scale custom hardware attacks by requiring large 
 * amounts of memory.
 * <p>
 * Even though its memory hardness can be significantly reduced at the cost of extra computations, this function 
 * remains an excellent choice today, provided that its parameters are properly chosen.
 * </p>
 * Scrypt is available in libsodium since version 0.5.0, which makes it a better choice than Argon2 if compatibility with older libsodium versions is a concern.
 * </blockquote>
 * 
 * @param passwd Array of bytes of password
 * @param salt Salt to use in key generation. The salt should be 
 * unpredictable and can be generated by calling {@link SodiumLibrary#randomBytes(int)}
 * The salt should be saved by the caller as it will be needed to derive the key again from the 
 * password.
 * @return key as an array of bytes
 * @throws SodiumLibraryException on error
 * @see <a href="https://download.libsodium.org/doc/password_hashing/" target="_blank">Password hashing</a>
 */
public static byte[] cryptoPwhashScrypt(byte[] passwd, byte[] salt) throws SodiumLibraryException
{
    NativeLong salt_length = sodium().crypto_pwhash_scryptsalsa208sha256_saltbytes();
    if (salt.length != salt_length.intValue())
    {
        throw new SodiumLibraryException("salt is " + salt.length + ", it must be" + salt_length + " bytes");
    }
    byte[] key = new byte[sodium().crypto_box_seedbytes().intValue()];
    int rc = sodium().crypto_pwhash_scryptsalsa208sha256(key, key.length, 
            passwd, passwd.length,
            salt,
            sodium().crypto_pwhash_opslimit_interactive(),
            sodium().crypto_pwhash_memlimit_interactive());
    
    logger.info("crypto_pwhash_scryptsalsa208sha256 returned: " + rc);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_pwhash_scryptsalsa208sha256() failed, returned " + rc + ", expected 0");
    }
    return key;
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:45,代码来源:SodiumLibrary.java

示例7: ClosureProxy

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
protected ClosureProxy(String signal, Closure closure) {
    this.closure = closure;

    Method invoke = null;
    for (Method m : closure.getClass().getDeclaredMethods()) {
        if (m.getName().equals(Closure.METHOD_NAME)) {
            invoke = m;
            break;
        }
    }
    if (invoke == null) {
        throw new IllegalArgumentException(closure.getClass() 
                + " does not have an invoke method");
    }
    invoke.setAccessible(true);
    this.method = invoke;
    //
    // The closure does not have a 'user_data' pointer, so push it in as the 
    // last arg.  The last arg will be dropped later in callback()
    //
    parameterTypes = new Class[method.getParameterTypes().length + 1];
    parameterTypes[parameterTypes.length - 1] = Pointer.class;
    for (int i = 0; i < method.getParameterTypes().length; ++i) {
        Class<?> paramType = method.getParameterTypes()[i];
        Class<?> nativeType = paramType;
        if (ClockTime.class.isAssignableFrom(paramType)) {
            nativeType = long.class;
        } else if (NativeObject.class.isAssignableFrom(paramType)) {
            nativeType = Pointer.class;
        } else if (Enum.class.isAssignableFrom(paramType)) {
            nativeType = int.class;
        } else if (String.class.isAssignableFrom(paramType)) {
            nativeType = Pointer.class;
        } else if (Boolean.class.isAssignableFrom(paramType)) {
            nativeType = int.class;
        }
        parameterTypes[i] = nativeType;
    }
    NativeLong connectID = GSIGNAL_API.g_signal_connect_data(GObject.this, 
            signal, this, null, null, 0);
    if (connectID.intValue() == 0) {
        throw new IllegalArgumentException(String.format("Failed to connect signal '%s'", signal));
    }
    this.id = connectID;
}
 
开发者ID:gstreamer-java,项目名称:gstreamer1.x-java,代码行数:46,代码来源:GObject.java

示例8: getLength

import com.sun.jna.NativeLong; //导入方法依赖的package包/类
public int getLength() {
  NativeLong nl = CFLibrary.INSTANCE.CFDataGetLength(this);
  return nl.intValue();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:5,代码来源:CFData.java


注:本文中的com.sun.jna.NativeLong.intValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。