Caesar Cypher Python使用RAD软件

Caesar Cypher Python使用RAD软件,python,caesar-cipher,Python,Caesar Cipher,因此,目前我正在开发一款凯撒密码应用程序,我的代码如下(由RAD软件编写) 问题是,当我试图运行程序时,我没有得到任何输出,我认为它可能是self.text\u area\u 2=cipher\u encrypt(纯文本,密钥)。我不确定是否使用了正确的语句来正确显示输出 我应该用什么语句来代替?我做的对吗 from ._anvil_designer import Form2Template from anvil import * class Form2(Form2Template):

因此,目前我正在开发一款凯撒密码应用程序,我的代码如下(由RAD软件编写)

问题是,当我试图运行程序时,我没有得到任何输出,我认为它可能是
self.text\u area\u 2=cipher\u encrypt(纯文本,密钥)
。我不确定是否使用了正确的语句来正确显示输出

我应该用什么语句来代替?我做的对吗


from ._anvil_designer import Form2Template
from anvil import *

class Form2(Form2Template):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)


  def button_1_click(self, **event_args): 

    def cipher_encrypt(plain_text, key):

      plain_text = self.text_area_1.text
      key = self.text_box_1.text

      encrypted = ""

      for c in plain_text:

        if c.isupper(): #check if it's an uppercase character

            c_index = ord(c) - ord('A')

            # shift the current character by key positions
            c_shifted = (c_index + key) % 26 + ord('A')

            c_new = chr(c_shifted)

            encrypted += c_new

        elif c.islower(): #check if its a lowecase character

            # subtract the unicode of 'a' to get index in [0-25) range
            c_index = ord(c) - ord('a') 

            c_shifted = (c_index + key) % 26 + ord('a')

            c_new = chr(c_shifted)

            encrypted += c_new

        elif c.isdigit():

            # if it's a number,shift its actual value 
            c_new = (int(c) + key) % 10

            encrypted += str(c_new)

        else:

            # if its neither alphabetical nor a number, just leave it like that
            encrypted += c

      return encrypted



    self.text_area_2 = cipher_encrypt(plain_text, key)