本文整理了Java中jnr.posix.POSIX.crypt()
方法的一些代码示例,展示了POSIX.crypt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.crypt()
方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:crypt
[英]Call the crypt function with the given key and salt as raw null-terminated byte (C char) strings.
[中]使用给定的密钥和salt作为原始的以null结尾的字节(C char)字符串调用crypt函数。
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
public CharSequence crypt(CharSequence key, CharSequence salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
public CharSequence crypt(CharSequence key, CharSequence salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: com.github.jnr/jnr-posix
public byte[] crypt(byte[] key, byte[] salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
public byte[] crypt(byte[] key, byte[] salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
public byte[] crypt(byte[] key, byte[] salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: com.github.jnr/jnr-posix
public byte[] crypt(byte[] key, byte[] salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: com.github.jnr/jnr-posix
public CharSequence crypt(CharSequence key, CharSequence salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
public CharSequence crypt(CharSequence key, CharSequence salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
public CharSequence crypt(CharSequence key, CharSequence salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: com.github.jnr/jnr-posix
public CharSequence crypt(CharSequence key, CharSequence salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
public byte[] crypt(byte[] key, byte[] salt) {
try { return posix.crypt(key, salt); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); }
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
public byte[] crypt(byte[] key, byte[] salt) {
return posix().crypt(key, salt);
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_str_crypt
*
*/
@JRubyMethod(name = "crypt")
public RubyString crypt(ThreadContext context, IRubyObject other) {
Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding();
RubyString otherStr = other.convertToString().strDup(context.runtime);
otherStr.modify();
otherStr.associateEncoding(ascii8bit);
ByteList otherBL = otherStr.getByteList();
if (otherBL.length() < 2) {
throw context.runtime.newArgumentError("salt too short (need >=2 bytes)");
}
POSIX posix = context.runtime.getPosix();
byte[] keyBytes = Arrays.copyOfRange(value.unsafeBytes(), value.begin(), value.begin() + value.realSize());
byte[] saltBytes = Arrays.copyOfRange(otherBL.unsafeBytes(), otherBL.begin(), otherBL.begin() + otherBL.realSize());
if (saltBytes[0] == 0 || saltBytes[1] == 0) {
throw context.runtime.newArgumentError("salt too short (need >=2 bytes)");
}
byte[] cryptedString = posix.crypt(keyBytes, saltBytes);
// We differ from MRI in that we do not process salt to make it work and we will
// return any errors via errno.
if (cryptedString == null) throw context.runtime.newErrnoFromInt(posix.errno());
RubyString result = RubyString.newStringNoCopy(context.runtime, cryptedString, 0, cryptedString.length - 1);
result.associateEncoding(ascii8bit);
result.infectBy(this);
result.infectBy(otherStr);
return result;
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_str_crypt
*
*/
@JRubyMethod(name = "crypt")
public RubyString crypt(ThreadContext context, IRubyObject other) {
Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding();
RubyString otherStr = other.convertToString().strDup(context.runtime);
otherStr.modify();
otherStr.associateEncoding(ascii8bit);
ByteList otherBL = otherStr.getByteList();
if (otherBL.length() < 2) {
throw context.runtime.newArgumentError("salt too short (need >=2 bytes)");
}
POSIX posix = context.runtime.getPosix();
byte[] keyBytes = Arrays.copyOfRange(value.unsafeBytes(), value.begin(), value.begin() + value.realSize());
byte[] saltBytes = Arrays.copyOfRange(otherBL.unsafeBytes(), otherBL.begin(), otherBL.begin() + otherBL.realSize());
if (saltBytes[0] == 0 || saltBytes[1] == 0) {
throw context.runtime.newArgumentError("salt too short (need >=2 bytes)");
}
byte[] cryptedString = posix.crypt(keyBytes, saltBytes);
// We differ from MRI in that we do not process salt to make it work and we will
// return any errors via errno.
if (cryptedString == null) throw context.runtime.newErrnoFromInt(posix.errno());
RubyString result = RubyString.newStringNoCopy(context.runtime, cryptedString, 0, cryptedString.length - 1);
result.associateEncoding(ascii8bit);
result.infectBy(this);
result.infectBy(otherStr);
return result;
}
内容来源于网络,如有侵权,请联系作者删除!