python实现HMAC算法与应用[通俗易懂]

python实现HMAC算法与应用[通俗易懂]Inthisprogram,youarerequiredtoinvokethealgorithmsthatareimplementedinbuild-inlibrary.Yourprogramdoesthefollowing:ExampleInputExampleOutputsolutioncodeoutput受于文本篇幅原因,本文相关算法实现工程例如环境及相关库,无法展示出来,现已将资源上传,可自行点击下方链接下载。python实现Hash和H

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

Program : HMAC

In this program, you are required to invoke the scrypt algorithms that are implemented in hashlib build-in library. Your program does the following:

  • Read the plaintext password as a text string
  • Encode the password into byte array, with utf-8 encoding
  • Read the salt byte array as a hex string
  • Invoke the scrypt method with parameters n = 4 n=4 n=4, r = 8 r=8 r=8, p = 16 p=16 p=16
  • Output the result byte array as a hex string

Example Input

Thi$ i$ my passw0rd!
477d15cb740ca1da08f6d851361b3c80

Jetbrains全家桶1年46,售后保障稳定

Example Output

fd5963b9e6905d36ca8d00e3a740a3ab7a40b3d60237b6f2ed3025eee770f2d71bc95ba3e98265bea4308250d02f0e10bb78e710d9f0ef7ae9a4fa52a0818d27

solution code

import hashlib
import base64

# define the function decode_utf8
def decode_utf8(in_bytes: bytes) -> str:
    return in_bytes.decode('utf-8')
#

 Read the plaintext password as a text string
password_str: str = input("input the plaintext password:")
# Encode the password into byte array, with utf-8 encoding
password_bytes: bytes = password_str.encode("utf-8")
# Read the salt byte array as a hex string
salt_str: str = input("input the salt:")
salt_bytes: bytes = bytes.fromhex(salt_str)
# Invoke the scrypt method with parameters n = 4 ,r = 8 ,p = 16
n: int = 4
r: int = 8
p: int = 16
result_bytes: bytes = hashlib.scrypt(password_bytes, salt=salt_bytes, n=n, r=r, p=p)
# Output the result byte array as a hex string
result_str: str = result_bytes.hex()
print(result_str)

output

input the plaintext password:Thi$ i$ my passw0rd!
input the salt:477d15cb740ca1da08f6d851361b3c80
fd5963b9e6905d36ca8d00e3a740a3ab7a40b3d60237b6f2ed3025eee770f2d71bc95ba3e98265bea4308250d02f0e10bb78e710d9f0ef7ae9a4fa52a0818d27

进程已结束,退出代码为 0

A screenshot of the console output of the program
在这里插入图片描述

受于文本篇幅原因,本文相关算法实现工程例如环境及相关库,无法展示出来,现已将资源上传,可自行点击下方链接下载。

python实现Hash和HMAC算法工程文件

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/215911.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • windowshello指纹识别器_win10指纹驱动安装失败

    windowshello指纹识别器_win10指纹驱动安装失败首先,需要确认你的电脑安装有指纹识别设备,有的笔记本自带的就是指纹扫描器(例如MS酋长的惠普248G1笔记本),没有的可以考虑加装外设型的指纹识别设备。并且确认已经安装了指纹识别设备的驱动程序,方法是打开“设备管理器”,在其中查看有无“生物识别设备”。如图:然后进入“设置–帐户–登录选项”,即可在右侧空格中找到“WindowsHello”设置项。如图:点击“指纹”下的“设置”按钮,会…

    2022年8月10日
    19
  • phpstorm激活码2022【中文破解版】

    (phpstorm激活码2022)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~747EFQ8BIF-eyJsaWNlb…

    2022年3月31日
    68
  • 分布式事务、cloud、boot、常规队列MQ、elk、kafuka

    分布式事务、cloud、boot、常规队列MQ、elk、kafuka点击链接》》》这个博客里面的专栏。apache-jmeter-3.3的简单压力测试使用方法https://www.cnblogs.com/ios9/p/7644951.html#_label3 

    2022年5月15日
    29
  • 主机游戏神作和排行榜

    主机游戏神作和排行榜文章目录主机游戏任天堂、索尼、微软三大家任天堂索尼微软其他电视游戏主机(家用机)红白机时代PS时代次世代主机掌机其他游戏PC游戏平台Steam其他评分和榜单端游、页游和手游评分和榜单VR设备ValveIndexHTCViveOculusRiftSOculusQuest三星MR+权威游戏评分媒体TGAIGNGameSpot其他GameRankingsFami通MetacriticEGA游戏…

    2022年7月11日
    81
  • 【windows屏幕扩展】把你多余屏幕利用起来,spacedesk屏幕扩展超低延迟解决方案[通俗易懂]

    【windows屏幕扩展】把你多余屏幕利用起来,spacedesk屏幕扩展超低延迟解决方案[通俗易懂]目录扫盲扫盲spacedesk是一款基于TCP/IP协议的屏幕扩展工具,通过这款工具你可以把自己身边的闲置的平板手机或者笔记本利用起来,扩展你的屏幕。只要你的两台设备处于同一个网络环境下(只要互相能够ping通),你就可以实现屏幕扩展(卡不卡我就不知道了)。用过win10中的wifi扩展屏幕的同学都知道,扩展的屏幕显示质量和网络环境成正比。而win10的屏幕扩展很玄学,…

    2022年8月13日
    3
  • MSDN 6.0 之 Platform SDK 内容导航

    MSDN 6.0 之 Platform SDK 内容导航MSDN6.0之PlatformSDK内容导航王天平,北京,荣丰20082005年7月3日从头文件说起实际上在每个用C编写的Windows程式的开头都可看到:#includeWINDOWS.H是主要的引入头文件,它包含了其他Windows头文件,这些头文件的某些也包含了其他头文件。这些头文件中最重要的和最基本的是:l        WINDEF.H基本类型定义。l        

    2022年6月3日
    57

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号