1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OSXのキーチェーンアクセスから秘密メモを取り出す

Last updated at Posted at 2015-05-23

日本語の情報がなかったので今後使うと思うのでメモ。

OSXのキーチェーンアクセスに秘密メモという項目に設定を持たせ、
スクリプトの中から使いたかったのです。

スクリーンショット 2015-05-23 14.10.33.png

  1. キーチェーンアクセスの秘密メモに項目を登録。(ここではmy_secret_info)
  2. コマンドラインから秘密メモを取り出す。
    security find-generic-password -C note -s my_secret_info -w > my_secret.txt
  3. 取り出した情報はバイナリ文字列かつXMLなので、メモ本体を取り出す。
sample.rb
require 'rexml/document'
str = open("my_secret.txt").read    
doc = REXML::Document.new str.split.pack("H*")    
puts doc.root.elements["dict/string"].text 

stackoverflowからの簡易説明でした。(あちらはPythonだったので)
http://stackoverflow.com/questions/22370552/keychain-services-secure-notes

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?