{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "⊕ [hashlib — Secure hashes and message digests — Python 3.7.4 documentation](https://docs.python.org/3/library/hashlib.html)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-10T14:30:38.265560Z",
     "start_time": "2019-09-10T14:30:38.246579Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> import hashlib\n",
    ">>> m = hashlib.sha256()\n",
    ">>> m.update(b\"Nobody inspects\")\n",
    ">>> m.update(b\" the spammish repetition\")\n",
    ">>> m.digest()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(m.digest_size, m.block_size)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-10T14:33:31.362704Z",
     "start_time": "2019-09-10T14:33:31.355612Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hashlib.sha224(b\"Nobody inspects the spammish repetition\").hexdigest()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-10T14:34:51.383519Z",
     "start_time": "2019-09-10T14:34:51.375429Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> h = hashlib.new('ripemd160')\n",
    ">>> h.update(b\"Nobody inspects the spammish repetition\")\n",
    ">>> h.hexdigest()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-10T14:38:16.736658Z",
     "start_time": "2019-09-10T14:38:16.723339Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r=hashlib.sha224(\"Nobody inspects the spammish repetition\".encode('utf-8')).hexdigest()\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-10T14:38:58.923150Z",
     "start_time": "2019-09-10T14:38:58.915737Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.encode('utf-8')\n",
    "# r.decode('utf-8')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
