message3<-c("RAISETHEFLAG")
message4<-substring(message3,1:12,1:12)
text7<-NULL
for(i in message4)
{
  text7<-c(text7,which(Polybius == i,arr.ind = TRUE)-1)
}
text7
message5<-c("PEACH")
message6<-substring(message5,1:5,1:5)
text8<-NULL
for(i in message6)
{
  text8<-c(text8,which(Polybius == i,arr.ind = TRUE)-1)
}
text8
#Convert the two numeric vectors into two character vectors
#Every two separate numbers are a set of characters
#Use loop and the reduce function to split and merge
text9<-NULL
for(i in 1:24)
{
  if(i%%2==0){text9<-c(text9,Reduce('paste0',(text7[(i-1):i])))}
}
text10<-NULL
for(i in 1:10){
  if(i%%2==0){text10<-c(text10,Reduce('paste0',(text8[(i-1):i])))}
}
text9
text10
text11<-as.numeric(text9)
text12<-as.numeric(text10)
text11
text12
#Add two vectors of different lengths.
#First define the third vector with a value of 0.
#The length is the product of the lengths of the two vectors.
#Then add them separately, and then take the length of the longest vector.
#Use the rep function to achieve
TextLength<-rep(0,length(text11)*length(text12))
text13<-(text11+TextLength)+(text12+TextLength)
text14<-text13[1:length(text11)]
text14
#Combine multiple numeric value in this vector into one whole string
#Use the paste function to combine
text15<-Reduce('paste0',text14)
text16<-substring(text15,1:24,1:24)
text17<-as.numeric(text16)
text18<-c(text17,sample(1:9,1))
text19<-NULL
for(i in 1:25){
  if(i%%5==0){text19<-c(text19,Reduce('paste0',(text18[(i-4):i])))}
}
text19
finaltext2<-paste(text19,collapse = " ")
finaltext2





message7<-c("LEMON")
message8<-substring(message7,1:5,1:5)
text20<-NULL
for(i in message8)
{
  text20<-c(text20,which(Polybius == i,arr.ind = TRUE)-1)
}
text20
Ciphertext1<-c("485218255953320831514438213349403524226048521843494834323518")
text21<-substring(Ciphertext1,1:60,1:60)
text22<-as.numeric(text21)
text22
text23<-NULL
for(i in 1:60)
{
  if(i%%2==0){text23<-c(text23,Reduce('paste0',(text22[(i-1):i])))}
}
text24<-NULL
for(i in 1:10){
  if(i%%2==0){text24<-c(text24,Reduce('paste0',(text20[(i-1):i])))}
}
text25<-as.numeric(text23)
text26<-as.numeric(text24)
TextLength1<-rep(0,length(text25)*length(text26))
text27<-(text25+TextLength1)-(text26+TextLength1)
text28<-text27[1:length(text25)]
#The output value is 1 larger than the actual coordinate of the letter (both rows and columns)
#Add 11 to the current numeric vector, that is, add one to the row and column
text29<-text28+11
#The original Ciphertext is added with a random digits
#Remove the negative number at the end of the vector
#Use the subset function to filter
text30<-subset(text29,text29>0)
text31<-Reduce('paste0',text30)
text32<-substring(text31,1:58,1:58)
text33<-as.numeric(text32)
text34<-NULL
for(i in seq(text33)){
  if(i%%2==0){text34<-c(text34,Polybius[text33[i-1],text33[i]])}
}
text34
plaintext2<-paste(text34,collapse = "")
plaintext2