{"id":5370,"date":"2017-03-10T00:01:21","date_gmt":"2017-03-09T15:01:21","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=5370"},"modified":"2017-05-17T14:53:34","modified_gmt":"2017-05-17T05:53:34","slug":"crypt_string_created_by_file_hash","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/crypt_string_created_by_file_hash.html","title":{"rendered":"\u30e1\u30c3\u30bb\u30fc\u30b8\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u6587\u5b57\u5217\u306e\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3092\u884c\u3046\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5eopenssl\u30b3\u30de\u30f3\u30c9\u3067AES\u306b\u3088\u308b\u5171\u901a\u9375\u3092\u7528\u3044\u305f\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3001\u30cf\u30c3\u30b7\u30e5\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0SHA-512\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u672c\u4f53\u304b\u3089\u30ad\u30fc\u3092\u751f\u6210\uff5e"},"content":{"rendered":"
AWS\u3001GCE\u3001Azure\u306a\u3069\u306e\u30d1\u30d6\u30ea\u30c3\u30af\u30af\u30e9\u30a6\u30c9\u306e\u666e\u53ca\u3084\u30b9\u30de\u30fc\u30c8\u30c7\u30d0\u30a4\u30b9\u3092\u7528\u3044\u305fIoT\u306e\u6d41\u308c\u306e\u4e2d\u3067\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u4ecb\u3057\u305f\u30c7\u30fc\u30bf\u901a\u4fe1\u306f\u5f53\u305f\u308a\u524d\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u3066\u304a\u308a\u3001\u6697\u53f7\u5316\u6280\u8853\u306f\u76ca\u3005\u91cd\u8981\u6027\u3092\u5897\u3057\u3066\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u4e00\u8a00\u3067\u6697\u53f7\u5316\u3068\u8a00\u3063\u3066\u3082\u3001\u6697\u53f7\u5316\u5bfe\u8c61\u306e\u30c7\u30fc\u30bf\u3084\u6697\u53f7\u5316\u65b9\u5f0f\u306a\u3069\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u3088\u308a\u3001\u69d8\u3005\u306a\u30d1\u30bf\u30fc\u30f3\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n
\u4eca\u56de\u306f\u305d\u3093\u306a\u69d8\u3005\u306a\u6697\u53f7\u5316\u65b9\u5f0f\u306e\u4e2d\u304b\u3089\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u672c\u4f53\u304b\u3089\u30cf\u30c3\u30b7\u30e5\u5024\u3067\u5171\u901a\u9375\u3092\u751f\u6210\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u6587\u5b57\u5217\u3092\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n
\u57fa\u672c\u65b9\u91dd\u3068\u3057\u3066\u306fopenssl\u30b3\u30de\u30f3\u30c9\u306e-des3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u7528\u3044\u3066AES\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u3088\u308b\u5171\u901a\u9375\u3067\u306e\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n
\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u306b\u4f7f\u7528\u3059\u308b\u5171\u901a\u9375\u306f\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u5316\u3092\u5b9f\u884c\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u305d\u306e\u3082\u306e\u306b\u5bfe\u3059\u308bSHA-512\u306e\u30d5\u30a1\u30a4\u30eb\u30cf\u30c3\u30b7\u30e5\u3092\u7528\u3044\u307e\u3059\u3002<\/p>\n
\u305d\u306e\u305f\u3081\u3001\u5168\u304f\u540c\u4e00\u306e\u5185\u5bb9\u306e\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3060\u3051\u304c\u6697\u53f7\u5316\u306b\u5bfe\u3059\u308b\u5fa9\u53f7\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n
\u3053\u308c\u306b\u3088\u308a\u3001\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u5909\u66f4\u3059\u308b\u3060\u3051\u3067\u9055\u3046\u5171\u901a\u9375\u306b\u3088\u308b\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3092\u884c\u3046\u3088\u3046\u306b\u306a\u308b\u305f\u3081\u3001\u8907\u6570\u7b87\u6240\u3067\u9055\u3046\u5171\u901a\u9375\u3092\u7528\u3044\u3066\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3059\u308b\u5834\u5408\u306b\u30b3\u30e1\u30f3\u30c8\u5909\u66f4\u306e\u307f\u3067\u5bb9\u6613\u306b\u79fb\u884c\u30fb\u79fb\u690d\u306a\u3069\u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n
\u305f\u3060\u3001\u4e00\u65b9\u3067\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u306e\u5185\u5bb9\u81ea\u4f53\u304c\u5171\u901a\u9375\u306e\u5143\u306b\u306a\u308b\u305f\u3081\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3078\u306e\u30a2\u30af\u30bb\u30b9\u7ba1\u7406\u3084\u6539\u3056\u3093\u306a\u3069\u306b\u306f\u5341\u5206\u306b\u6ce8\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n
\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u306e\u5185\u5bb9\u306f\u4e0b\u8a18\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u3042\u308b<\/p>\n
\u300c#*****\u3053\u3053\u306b\u4f7f\u7528\u3059\u308b\u9375\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8f09\u3059\u308b*****\u300d<\/p>\n
\u3068\u3044\u3046\u90e8\u5206\u306b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u6bce\u306b\u5171\u901a\u9375\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n
sha512sum\u30b3\u30de\u30f3\u30c9\u3067\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u81ea\u4f53\u306b\u30cf\u30c3\u30b7\u30e5\u3092\u304b\u3051\u3066\u9375\u3092\u751f\u6210\u3059\u308b\u306e\u3067\u3001\u30b3\u30e1\u30f3\u30c8\u5185\u5bb9\u306f\u4f55\u3067\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<\/p>\n
\u308f\u305a\u304b\u306a\u30b3\u30e1\u30f3\u30c8\u306e\u9055\u3044(\u30b9\u30da\u30fc\u30b9\u3001\u30bf\u30d6\u3001\u6539\u884c)\u3067\u3082\u5171\u901a\u9375\u304c\u5909\u308f\u3063\u3066\u304f\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n
\r\n[magtranetwork@localhost ~]# vim crypt_string.sh\r\n<\/pre>\n\r\n#!\/bin\/bash\r\n \r\n#*****\u3053\u3053\u306b\u4f7f\u7528\u3059\u308b\u9375\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8f09\u3059\u308b*****\r\n \r\n#\u5fa9\u53f7\u6642\u306e\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u4fdd\u7ba1\u5834\u6240\u3092\u6307\u5b9a\u3059\u308b\u3002\r\nTMP_DIR=\/tmp\r\nTMP_FILE_NAME=crypt_string\r\n \r\n#\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b58\u5728\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u3078\u79fb\u52d5\u3059\u308b\u3002\r\ncd `dirname $0`\r\n#\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b58\u5728\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u3092\u53d6\u5f97\u3002\r\nCUR_DIR=`pwd`\r\n#\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u540d\u79f0\u3092\u53d6\u5f97\u3059\u308b\u3002\r\nMYNAME=$(basename $0)\r\n \r\n#sha512sum\u3067\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u53d6\u5f97\u3057\u3001\u79d8\u5bc6\u9375\u3068\u3059\u308b\u3002\r\nKEY=`sha512sum ${CUR_DIR}\/${MYNAME} | awk '{print $1}' | tr -d '\\n'`\r\n \r\n#\u6697\u53f7\u5316\u3001\u5fa9\u53f7\u306e\u51e6\u7406\u30e2\u30fc\u30c9\u3092\u5f15\u6570\u304b\u3089\u53d6\u5f97\r\nMODE=$1\r\n \r\n#\u6697\u53f7\u5316\u3001\u5fa9\u53f7\u306e\u5bfe\u8c61\u6587\u5b57\u5217\u3092\u5f15\u6570\u304b\u3089\u53d6\u5f97\r\nSTR=${@:2}\r\n \r\n#\u51e6\u7406\u30e2\u30fc\u30c9\u306e\u6587\u5b57\u5217\u3092\u5168\u3066\u5c0f\u6587\u5b57\u306b\u3059\u308b\u3002\r\nMODE=`echo "${MODE}" | tr 'A-Z' 'a-z'`\r\n \r\n \r\nif [ "${MODE}" = "enc" ]; then\r\n #\u51e6\u7406\u30e2\u30fc\u30c9\u304cenc\u306e\u5834\u5408\u3001openssl\u30b3\u30de\u30f3\u30c9\u3092\u7528\u3044\u3066\u6697\u53f7\u5316\u51e6\u7406\u3092\u884c\u3044\u3001\u6539\u884c\u3092\u524a\u9664\u3057\u3066\u6a19\u6e96\u51fa\u529b\u3059\u308b\u3002\r\n echo "${STR}" | openssl enc -e -aes-256-cbc -base64 -k "${KEY}" | tr -d '\\n'\r\nelif [ "${MODE}" = "dec" ]; then\r\n #\u5fa9\u53f7\u6642\u306e\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6642\u523b\u3088\u308a\u4f5c\u6210\u3059\u308b\u3002\r\n DATE_STR=`date +"%Y%m%d%H%M%S"`\r\n #\u5165\u529b\u3055\u308c\u305f\u6587\u5b57\u5217\u309264\u6587\u5b57\u76ee\u3067\u6539\u884c\u3092\u884c\u3044base64\u306e\u5f62\u5f0f\u306b\u623b\u3057\u3001\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u51fa\u3059\u3002\r\n echo "${STR}" | fold -64 > ${TMP_DIR}\/${TMP_FILE_NAME}_${DATE_STR}\r\n #\u51e6\u7406\u30e2\u30fc\u30c9\u304cdec\u306e\u5834\u5408\u3001openssl\u30b3\u30de\u30f3\u30c9\u3092\u7528\u3044\u3066\u5fa9\u53f7\u51e6\u7406\u3092\u884c\u3046\u3002\r\n openssl enc -d -aes-256-cbc -base64 -k "${KEY}" -in ${TMP_DIR}\/${TMP_FILE_NAME}_${DATE_STR}\r\n #\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u524a\u9664\r\n rm -f ${TMP_DIR}\/${TMP_FILE_NAME}_${DATE_STR}\r\nelse\r\n #\u51e6\u7406\u30e2\u30fc\u30c9\u6587\u5b57\u5217\u304cenc, dec\u4ee5\u5916\u306e\u5834\u5408\u306f\u4f7f\u7528\u65b9\u6cd5\u3092\u8868\u793a\u3002\r\n echo "Usage: ${CUR_DIR}\/${MYNAME} [enc|dec] [STRING]"\r\nfi\r\n<\/pre>\n\u30e1\u30c3\u30bb\u30fc\u30b8\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u6587\u5b57\u5217\u306e\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3092\u884c\u3046\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u306e\u5b9f\u884c\u4f8b<\/h3>\n
\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u300ccrypt_string.sh\u300d\u306e\u5b9f\u884c\u4f8b\u3092\u6697\u53f7\u5316\u3001\u5fa9\u53f7\u305d\u308c\u305e\u308c\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n
\u6697\u53f7\u5316\u306fenc\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u7528\u3044\u3066\u884c\u3044\u3001\u5fa9\u53f7\u306fdec\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u7528\u3044\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n
\u6697\u53f7\u5316\u3001\u5fa9\u53f7\u3069\u3061\u3089\u30822\u3064\u76ee\u306e\u5f15\u6570\u4ee5\u964d(enc\u307e\u305f\u306fdec\u4ee5\u964d)\u3092\u5168\u3066\u6697\u53f7\u5316\u3001\u5fa9\u53f7\u306e\u5bfe\u8c61\u6587\u5b57\u5217\u3068\u3057\u3066\u8a8d\u8b58\u3059\u308b\u306e\u3067\u3001\u6587\u5b57\u5217\u306b\u30b9\u30da\u30fc\u30b9\u7b49\u304c\u542b\u307e\u308c\u3066\u3044\u3066\u3082\u8a8d\u8b58\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300c”\u300d\u305d\u306e\u3082\u306e\u3092\u5bfe\u8c61\u6587\u5b57\u5217\u3068\u3059\u308b\u5834\u5408\u306f\u300c\\”\u300d\u306e\u3088\u3046\u306b\u300c\\\u300d\u8a18\u53f7\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n
\r\n[magtranetwork@localhost ~]# chmod 755 crypt_string.sh\r\n\r\n[magtranetwork@localhost ~]# .\/crypt_string.sh enc magtranetwork.com\r\nU2FsdGVkX1\/1ouFheXVmVzFTu\/zsfcjc\/08w5uKhOak=\r\n\r\n[magtranetwork@localhost ~]# .\/crypt_string.sh dec U2FsdGVkX1\/1ouFheXVmVzFTu\/zsfcjc\/08w5uKhOak=\r\nmagtranetwork.com\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"AWS\u3001GCE\u3001Azure\u306a\u3069\u306e\u30d1\u30d6\u30ea\u30c3\u30af\u30af\u30e9\u30a6\u30c9\u306e\u666e\u53ca\u3084\u30b9\u30de\u30fc\u30c8\u30c7\u30d0\u30a4\u30b9\u3092\u7528\u3044\u305fIoT\u306e\u6d41\u308c\u306e\u4e2d\u3067\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u4ecb\u3057\u305f\u30c7\u30fc\u30bf\u901a\u4fe1\u306f\u5f53\u305f\u308a\u524d\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u3066\u304a\u308a\u3001\u6697\u53f7\u5316\u6280\u8853\u306f\u76ca\u3005\u91cd\u8981\u6027\u3092\u5897\u3057\u3066\u304d\u3066\u3044\u307e\u3059\u3002 \u4e00\u8a00\u3067\u6697\u53f7 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3,22,79,82],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5370"}],"collection":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/comments?post=5370"}],"version-history":[{"count":10,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5370\/revisions"}],"predecessor-version":[{"id":5641,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5370\/revisions\/5641"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=5370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=5370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=5370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}