uwsgi: option is ambiguous: http
利用qq邮箱作为个人邮件服务器发送邮件

用最简单方法解决api接口安全问题,几乎无法破解

妙音 posted @ 2019年1月01日 11:45 in python with tags web python , 7749 阅读
 

 场景描述

 
项目需要为第三方提供api服务接口。接口涉及到核心功能,如何保证接口安全。防止伪造身份、篡改数据?
 

思路

 
保障数据安全最好的方法,当然是加密了。无法解析内容,自然无法伪造,篡改。

可是使用https证书需要收费的。有其它方法么?

有的。

消息哈希认证(hmac)。
 
 

 算法描述

 
*  访问者
 
1. 当访问接口时, 将参数按key值排序,组成key1=value1&key2=value2&....&secret_key=...
2. 然后对上面结果做md5,生成签名sign
3. 将sign放到加入请求的参数
 
* 被访问者
 
密钥是被访问者提供了,它也有访问者的secret_key.
1.根据app_id查到secret_key
2.处理请求参数,按规则组成key1=value1&key2=value2....&secret_key=...
3.对上一步结果做md5,生成sign。比较两个sign,相等则身份验证通过
 

效果

 
1. 密钥只存在双方机器上,不可能被截取
2. 签名无法伪造,同样身份无法伪造、消息无法被篡改
 
使用了hmac认证,接口被破解基本是不可能的
 

python实现

 
import md5

app_id=123
secret_key="xxxxxxxx"

request_param = dict(
    key1="value1",
    key2="value2",
    key3="value3"
)

def sign():
    params = ["%s=%s" % (key, value) for key, value in sorted(request_param.items(), key=lambda item: item[0])]
    params.append("secret_key=%s" % secret_key)
    str_param = "&".join(params)
    print str_param
    md = md5.md5()
    md.update(str_param)
    return md.hexdigest()

if __name__ == '__main__':
    print(sign())
 
 
来源
 

 

Avatar_small
Branded Eyeliners 说:
2020年10月08日 17:33

Eve’s Luxury is a Platform to make the availability of makeup and cosmetics products. We offer top-quality makeup products and beauty cosmetics. Branded Eyeliners

Avatar_small
How To Redeem KBC Pl 说:
2020年10月09日 15:16

thanks for this usefull article, waiting for this article like this again. How To Redeem KBC Play Along Points

Avatar_small
บาคาร่า1688 说:
2020年10月12日 19:00

Play Baccarat Online and Online Slots The best quality in Thailand with "SLOTBAR888" Auto deposit-withdrawal in just 30 seconds, play a variety of games in one place. Both online baccarat Online casino, online slots, fish shooting games that will keep you entertained 24 hours a day. บาคาร่า1688

Avatar_small
Twitch 说:
2020年10月12日 22:05

Twitch is the world's leading live streaming platform for gamers and the things we love. Watch and chat now with millions of other fans from around the world.

Avatar_small
chagoury 说:
2020年10月13日 21:56

Insights from Ronald chagoury Africa is on the verge of an explosive growth, and now is the time to invest Chagoury Group

Avatar_small
Homeworkmarket 说:
2020年10月15日 22:27

Homeworkmarket for all students. We have professional Homework writers with years of experience in academic writing. We have Assisted thousands of students with their homework.

Avatar_small
american straws 说:
2020年10月16日 17:38
Wheat straws are the most compostable and affordable alternatives to paper and single-use plastic straws. Our straws are made from the stem of the wheat stalk american straws
 

 

Avatar_small
שרת וירטואלי 说:
2020年10月16日 23:54

Your article is extremely helpful exceptionally fascinating subject i am looking that sort of post thank for imparting to us keep it up. שרת וירטואלי

Avatar_small
שרת וירטואלי 说:
2020年10月17日 04:19

Buffalo wings or more famously called as Chicken wings are fried chicken wings coated with sauce. Traditional Filipino Cooking Recipes

Avatar_small
먹튀폴리스 说:
2020年10月23日 04:14

Persons appreciate shopping for amazing, appealing, fascinating and from time to time attractive aromas for them selves and pertaining to others. This can be executed conveniently along with inexpensively in an on-line perfume shop. 먹튀폴리스

Avatar_small
토토사이트 说:
2020年10月24日 21:48

Impressive web site, Distinguished feedback that I can tackle. I am moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards 토토사이트

Avatar_small
온라인릴게임 说:
2020年10月25日 20:51

Your article is extremely helpful exceptionally fascinating subject i am looking that sort of post thank for imparting to us keep it up. 온라인릴게임

Avatar_small
موقع قصة عشق 说:
2020年10月26日 16:14

Welcome to the story of love for the latest Turkish series and drama, through the story of love, you can follow everything new in the world of Turkish drama موقع قصة عشق

Avatar_small
lô xiên 3 说:
2020年10月27日 16:51

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. lô xiên 3

Avatar_small
DRM 说:
2020年11月02日 01:13

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. DRM

Avatar_small
mercedes vin decoder 说:
2020年11月03日 01:02

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. mercedes vin decoder

Avatar_small
f88tw 说:
2020年11月03日 14:26

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw|墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|火化|晋塔|安葬|法事|捡骨|看日子|墓穴|墓园|坟墓|看日子|乞丐|http://mypaper.m.pchome.com.tw/f88tw

Avatar_small
All Season Tires Ott 说:
2020年11月08日 19:45

I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. All Season Tires Ottawa

Avatar_small
helphub 说:
2020年11月11日 02:09 definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog! lowes 10% off coupons
Avatar_small
helphub 说:
2020年11月11日 03:26

pleasant post, stay aware of this fascinating work. It truly regards realize that this subject is being secured likewise on this site so cheers for setting aside time to talk about this! office rental space

Avatar_small
Bodyguard Germany 说:
2020年11月12日 02:05

Just pure classic stuff from you here. I have never seen such a brilliantly written article in a long time. I am thankful to you that you produced this! Bodyguard Germany

Avatar_small
Emmas Sex Store 说:
2020年11月14日 02:41

I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Emmas Sex Store

Avatar_small
buy soma 500 说:
2020年11月21日 16:14

Toto site should be used carefully. In the case of signing up to the Toto site by using money, there is a high possibility that most of the damage will be caused. is. Before using the Toto site, it is an essential element. 먹튀검증

Avatar_small
desinfektionsmittel 说:
2020年11月23日 23:39

Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! desinfektionsmittel test

Avatar_small
Where to buy banana 说:
2020年11月25日 01:13

I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Where to buy banana poundcake strain

Avatar_small
Sit to Stand Desktop 说:
2020年11月26日 01:41

It turns out that even the hottest port has a few places where you can get off the beaten path. Here are some recommendations that will make you feel like you're in the know Sit to Stand Desktop Worskstation

Avatar_small
Best Laptop Football 说:
2020年11月27日 02:35

Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles Best Laptop Football Manager 2021

Avatar_small
contemporary ceramic 说:
2020年11月28日 15:11

Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles contemporary ceramics

Avatar_small
no excuses runner 说:
2020年12月01日 22:44

I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. instagram otomatik beğeni satın al

Avatar_small
Portugal property 说:
2020年12月15日 18:48

For a long time me & my friend were searching for informative blogs, but now I am on the right place guys, you have made a room in my heart! Portugal property

Avatar_small
REDUTROL COMO TOMAR 说:
2020年12月17日 00:46

This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: REDUTROL COMO TOMAR

Avatar_small
먹튀사이트 说:
2020年12月18日 05:14

I want to say thanks for beautiful blog sharing with us. Your blog really great resource to update my knowledge. 먹튀사이트

Avatar_small
Car Shield 说:
2020年12月18日 14:20

pleasant post, stay aware of this fascinating work. It truly regards realize that this subject is being secured likewise on this site so cheers for setting aside time to talk about this! Car Shield

Avatar_small
BUY LSD ONLINE 说:
2020年12月18日 18:34

I truly value this superb post that you have accommodated us. I guarantee this would be helpful for a large portion of the general population. BUY MUSHROOMS ONLINE

Avatar_small
buy counterfeit USA 说:
2020年12月20日 01:06

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks

Avatar_small
buy counterfeit USA 说:
2020年12月20日 01:12

I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up.

Avatar_small
Yacht security 说:
2020年12月21日 00:35

A lot of people having an incorrect image about the cash advance loans or sometimes refer it as bad credit payday loans. Yacht security

Avatar_small
no excuses runner 说:
2020年12月21日 21:42

Online sports betting services, online casinos Available 24 hours a day, you can deposit and withdraw anytime you want. We provide a fast entry service through the web page. Online football betting website Popular No. 1 Direct Representative from UEFA Bet That are popular to use Most in Thailand Accept online sports betting and all types of casinos. 24/7 customer service, 24 hours a day, no holidays. เว็บพนัน UFABET

Avatar_small
plastic back scratch 说:
2020年12月22日 21:47

Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.

Avatar_small
sofa bed melbourne 说:
2020年12月23日 14:20

Whoi, excellent, t wondered just how to cure icne. ind found your webstte by google, dtscovered todiy t'm i ltttle obvtous i greit deil. t’ve ilso idded RSS ind sive your webstte. keep us updited. sofa bed melbourne

Avatar_small
slack birthday app 说:
2020年12月24日 21:19

Your birthday isn't all about you anymore.* Cupcake celebrates your team's birthdays with a donation to a charity of their choice. _Must be located in the United States to use Cupcake at this time. slack birthday app

Avatar_small
no excuses runner 说:
2020年12月26日 19:11

Extremely intriguing online journal. A lot of web journals I see nowadays don't generally give anything that I'm keen on, however I'm most definitely inspired by this one. Recently felt that I would post and let you know. no excuses runner

Avatar_small
szpilki pleaser 说:
2020年12月26日 23:44

buty na wysokie obcasy polska sklep internetowy by www.obuwie-buty.com szpilki pleaser

Avatar_small
PLANT BASED FOOD PRO 说:
2020年12月27日 19:32

Extremely pleasant article, I appreciated perusing your post, exceptionally decent share, I need to twit this to my adherents. Much appreciated!.  PLANT BASED FOOD PROGRAMME

Avatar_small
buy lsd 说:
2020年12月28日 02:26

Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing.  buy lsd

Avatar_small
Situs Judi Online Pk 说:
2021年1月03日 23:19

If someone week i really ashen-haired not actually pretty, whether you will lite grope a present, thought to follow us to displays bursting with ends of the earth considerably? Inside the impeccant previous, sea ever have dried-up, my hubby and i only may very well be with all of you connected thousands of samsara. 3d light

Avatar_small
Betfair vedonlyöntib 说:
2021年1月04日 15:04

This is my first time i visit here. I found such a substantial number of interesting stuff in your blog especially its examination. Really its inconceivable article. Keep it up. Betfair vedonlyöntibonus

Avatar_small
Latex resistance ban 说:
2021年1月05日 22:30

Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. Latex resistance bands

Avatar_small
Latest women collect 说:
2021年1月06日 15:10

sdhI really like your blog. Great article. It's most evident, people should learn before they are able to Latest women collection

Avatar_small
Lsd 说:
2021年1月06日 20:24

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up Lsd

Avatar_small
Savory 说:
2021年1月08日 16:41

I truly value this superb post that you have accommodated us. I guarantee this would be helpful for a large portion of the general population. Savory

Avatar_small
formula 1 2021 说:
2021年1月09日 02:24

This is extremely fascinating substance! I have completely delighted in perusing your focuses and have reached the conclusion that you are right about a hefty portion of them. You are extraordinary.  <a href="http://f1daily.ca/">formula 1 2021</a>

Avatar_small
central ac contracto 说:
2021年1月09日 20:06

Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. central ac contractors

Avatar_small
인싸포커 说:
2021年1月10日 02:23

Recommended Information on Hold'em Sites in Korea 인싸포커

Avatar_small
bridal gowns leeds 说:
2021年1月11日 16:53

Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. bridal gowns leeds


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter