简体   繁体   English

有没有办法在Ruby Watir自动化脚本中加密密码?

[英]Is there a way to encrypt passwords in Ruby Watir automation scripts?

I need to create an automated test using Watir that requires a password to be written into a text field, but I don't want to have the password in plain view in the script. 我需要使用Watir创建一个自动测试,该测试需要将密码写入文本字段,但是我不想在脚本的普通视图中使用该密码。 Is there a way to encrypt/decrypt a password within Watir? 有没有办法在Watir中加密/解密密码?

I know python uses the base64 lib to do it, but I'm not sure how Ruby would do it. 我知道python使用base64 lib来做到这一点,但是我不确定Ruby将如何做到这一点。

Here's the code: 这是代码:

require 'watir'
ie = IE.new
ie.goto("https://test.domain.com")
ie.text_field(:name, "username").set("myUsername")
ie.textfield(:name, "password")set("myPassword")

Your test server shouldn't have sensitive data, and it shouldn't be publicly accessible. 您的测试服务器不应包含敏感数据,也不应公开访问。 What danger are you trying to protect against / what damage can an unauthorized person do if they got the password? 您试图防止什么危险/未经授权的人获得密码会对他们造成什么损害? If it's really a test server, it seems like the worst case is that someone would mess with your test data. 如果它确实是一个测试服务器,那么似乎最坏的情况是有人会弄乱您的测试数据。

Using base64 would only be security by obscurity because it's so easy to decode. 使用base64只能说是安全性,因为它很容易解码。 If you really think this is sufficient for your needs, just use Base64.encode64 and Base64.decode64 . 如果您真的认为这足以满足需要,请使用Base64.encode64Base64.decode64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM