Method: Keychain.create
- Defined in:
- lib/keychain.rb
.create(path, password = nil) ⇒ Keychain::Keychain
creates a new keychain file and adds it to the keychain search path ( SecKeychainCreate )
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/keychain.rb', line 23 def create(path, password=nil) path = path.encode(Encoding::UTF_8) out_buffer = FFI::MemoryPointer.new(:pointer) if password password = password.encode(Encoding::UTF_8) status = Sec.SecKeychainCreate(path, password.bytesize, FFI::MemoryPointer.from_string(password), 0, nil, out_buffer) else status = Sec.SecKeychainCreate(path, 0, nil, 1, nil, out_buffer) end Sec.check_osstatus(status) Keychain.new(out_buffer.read_pointer).release_on_gc end |